<?php


class BatchacmSubmissionUpdateWidget extends CWidget {

    public $submission;

    public function run(){
        if (isset($_POST['Submission'])){
            $this->submission->setScenario('update');
            $this->submission->setAttributes($_POST['Submission']);
            $this->submission->save();
        }

        $sid = $this->submission->id;
        $contest_id = $this->submission->contest_id;
        $submitter_id = $this->submission->submitter_id;
        $problem_id = $this->submission->problem_id;

        $subs = Submission::model()->findAll(array(
                'condition' => "score = 0 AND id < $sid AND submitter_id = $submitter_id AND problem_id = $problem_id AND contest_id = $contest_id"
            ));
        $prev_subs = count($subs);

        $this->render('submissionupdate', array(
            'submission' => $this->submission,
            'prev_subs' => $prev_subs,
        ));
    }
    
}